/*
 * Project: daycare-ent
 * Package: com.made2ordersoftware.daycare.domain
 * File: AddressEntity
 * Created on: Sep 15, 2013
 */
/**
 * Copyright (c) 2010 Made 2 Order Software, LLC
 *
 * All rights reserved. No part of this software may be reproduced, stored in a retrieval system, or
 * transmitted in any form or by any means, without the prior written permission of Made 2 Order Software.
 *
 * You may not distribute the URL or redistribute the files to third parties. You may transfer the files onto
 * a single storage device so long as you can prove ownership of the software. You may not reverse engineer,
 * decompile, or disassemble the software or media files. You may not modify or translate the software or
 * media, or distribute copies of the software or media without the written consent of Made 2 Order Software,
 * LLC.
 */
package com.made2ordersoftware.daycare.domain;

import java.io.Serializable;
import java.util.Objects;
import javax.persistence.Basic;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.made2ordersoftware.daycare.domain.enums.AddressType;
import com.made2ordersoftware.daycare.domain.enums.State;
import com.made2ordersoftware.util.StringUtility;
import javax.xml.bind.annotation.XmlRootElement;

/**
 * Entity class representing the address of registered parents with the day care.
 *
 * @author David Canning <dcannin@gmail.com>
 * @version 1.0.0
 */
@Entity
@Table(name = "address")
@XmlRootElement
public class AddressEntity implements Serializable {

    private static final Logger LOG = LoggerFactory.getLogger(AddressEntity.class);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    private Long id;
    @Basic(optional = false)
    private String street;
    @Basic(optional = false)
    private String city;
    @Basic(optional = false)
    @Enumerated(EnumType.STRING)
    private State state;
    @Basic(optional = false)
    private String zip;
    @Basic(optional = false)
    @Enumerated(EnumType.STRING)
    private AddressType type;
    @JoinColumn(name = "person_id")
    @ManyToOne(fetch = FetchType.EAGER)
    private ParentEntity parent;

    /**
     * Create an instance of <code>AddressEntity</code>.
     */
    public AddressEntity() {
    }

    /**
     * Create an instance of <code>AddressEntity</code>.
     *
     * @param street
     * @param city
     * @param state
     * @param zip
     * @param type
     */
    public AddressEntity(String street, String city, State state, String zip, AddressType type) {
        this.street = street;
        this.city = city;
        this.state = state;
        this.zip = zip;
        this.type = type;
    }

    /**
     *
     * @return the id
     */
    public Long getId() {
        return id;
    }

    /**
     * Sets the id
     *
     * @param id
     */
    public void setId(Long id) {
        this.id = id;
    }

    /**
     * @return the street
     */
    public String getStreet() {
        return street;
    }

    /**
     * Sets the street
     *
     * @param street the street to set
     */
    public void setStreet(String street) {
        this.street = street;
    }

    /**
     * Sets the city
     *
     * @return the city
     */
    public String getCity() {
        return city;
    }

    /**
     * @param city the city to set
     */
    public void setCity(String city) {
        this.city = city;
    }

    /**
     * @return the state
     */
    public State getState() {
        return state;
    }

    /**
     * Sets the state
     *
     * @param state the state to set
     */
    public void setState(State state) {
        this.state = state;
    }

    /**
     * @return the zip
     */
    public String getZip() {
        return zip;
    }

    /**
     * Sets the zip
     *
     * @param zip the zip to set
     */
    public void setZip(String zip) {
        this.zip = zip;
    }

    /**
     *
     * @return the type
     */
    public AddressType getType() {
        return type;
    }

    /**
     * Sets the type
     *
     * @param type
     */
    public void setType(AddressType type) {
        this.type = type;
    }

    /**
     *
     * @return the parent
     */
    public ParentEntity getParent() {
        return parent;
    }

    /**
     * Sets the parent
     *
     * @param parent
     */
    public void setParent(ParentEntity parent) {
        this.parent = parent;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 59 * hash + Objects.hashCode(this.id);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof AddressEntity)) {
            return false;
        }
        AddressEntity other = (AddressEntity) object;
        return Objects.equals(this.id, other.getId());
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder("\nAddressEntity{ id=").append(
                StringUtility.ifNotNullToString(getId()));
        sb.append("\n\tStreet=").append(this.street);
        sb.append("\n\tState=").append(this.state);
        sb.append("\n\tCity=").append(this.city);
        sb.append("\n\tZip=").append(this.zip);
        sb.append("\n\tType=").append(this.type);
        sb.append("}");
        return sb.toString();
    }

}
